#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> 

int main(void)
{
	char buf[1024]="\0";
	int fd[2];
	pipe(fd);
	pid_t pid;
	pid=fork();
	if (pid==0)
	{
		close(fd[0]);
		dup2(fd[1],fileno(stdout));
		execl("/bin/ls", "ls", "-l", NULL);
	}else
		if (pid!=0)
	{
		close(fd[1]);
		read(fd[0],buf, 1024);
		printf("%s\n--end", buf);
		close(fd[0]);
		wait(0);
	}
	return 0;	
}